Copyright: TLED: Copyright © 1997 Gary Hardman


TLED Component

Properties	Methods	Events

Unit

LED

Description

The TLED component emulates the behaviour of a Light Emitting Diode electronic component, and can be dropped onto a form (or container component) to provide a visual on or off indication of any Boolean variable.

An LED control can be Red, Green or Yellow, as determined by the Color property.

A Boolean Lit property determines whether the LED is painted dark (off) or bright (on).

If the LED is not Enabled it is painted in the background colour of its container component and appears 'grayed'.

TLED is a visual component descended directly from TGraphicControl.  As a result, LED controls have no window handles and have a negligible impact on system resources.

Efficient use of system resources is further preserved by loading only a single instance of the single bitmap required to paint an LED in all of its states into memory, regardless of the number of LED controls created.

Installation

Author


Properties

Color	Cursor	Enabled

Hint	Left	Lit

Name	ParentShowHint	ShowHint

Tag	Top	Visible


Methods

Create	Destroy

ChangeColor	ChangeState


Events

OnClick	OnChangeState	OnDblClick

OnDragDrop	OnDragOver	OnEndDrag

OnMouseDown	OnMouseMove	OnMouseUp


Color Property

Example

Applies to

TLED component

Declaration

TLEDColor = (lcRed, lcGreen, lcYellow);

Description

The TLEDColor type defines the values which determine the painted colour of the LED control.

If the Enabled property is False then the LED appears 'grayed'.


Lit Property

Example

Applies to

TLED component

Declaration

property Lit : Boolean;

Description

Lit	Value	Meaning

False	The LED is painted in dark colours, and so appears 'off '.

True	The LED is painted in light colours and so appears 'on'.

The value of the Enabled property determines whether the LED is painted in the selected colour and state, or appears 'grayed'.


Enabled Property

Applies to

TLED component

Declaration

property Enabled: Boolean;

Description

The Enabled property determines whether the LED control responds to mouse events.

If Enabled is True, the control responds normally. If Enabled is False, the control ignores mouse events.

Disabled LED controls appear 'grayed'.


ChangeState Method

Example

Applies to

TLED component

Declaration

function ChangeState : Boolean;

Description

Each call to the ChangeState method toggles the Lit state of the LED control.

It returns the new Boolean state of the controls Lit property.

Initial state	ChangeState	Return value

Lit = True	Lit := False	False

Lit = False	Lit := True	True


ChangeColor Method

Example

Applies to

TLED component

Declaration

function ChangeColor : TLEDColor;

Description

This function can be used to cycle through the LED control colours.

It returns the new TLEDColor value of the controls Color property.

Initial colour	New colour	Return value

lcRed	lcGreen	lcGreen

lcGreen	lcYellow	lcYellow

lcYellow	lcRed	lcRed


OnChangeState Event

Applies to

TLED component

Declaration

property OnChangeState : TNotifyEvent;

Description

The OnChangeState event is activated when the Lit property of the LED control is modified either directly or following a call to the ChangeState method.

You can take any special actions required by the event by assigning a method to this property.


Author; Disclaimer
The Author

Applies to

TLED component

I would be pleased to hear from anybody who uses (or chooses not to use) this component in their programming, not only to get an idea of how widely it is being used but also to receive comments, suggestions and bug reports.

Please send me an e-mail even if it looks like:  "Hi,  I'm using your TLED component", or otherwise.

btw. Does anyone out there want to share experiences on Win95 MIDI programming?

Disclaimer

This TLED component is released 'as is'.

I believe that this TLED component is robust, that there are no nasty bugs and it is generally of 'commercial quality', however, the author disclaims all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose.  The author assumes no liability for damages, direct or consequential, which may result from the use of this TLED component or the information contained herein.

Please contact me (Gary Bradley Hardman) by:

E-mail:

CompuServe: 71003,3205

Internet:  71003.3205@compuserve.com


Example

This example tests the colour of a TLED control at run time, changing it to Yellow if it is currently Red.

if LED1.Color = lcRed then LED1.Color := lcYellow;


Example

This example lights the LED control at run time:

LED1.Lit := True;

This example changes the caption of the main application form to reflect the current Lit state of the LED control:

case LED1.Lit of

  True:  Caption := 'The LED is Lit';

  False: Caption := 'The LED is not Lit';

end; {case}


Example

This example toggles the LED control on and off each time it is clicked, changing the Forms caption to reflect the new state:

procedure TForm1.LED1Click(Sender: TObject);

begin

   case TLED(Sender).ChangeState of

     True:  Caption := 'LED is Lit';

     False: Caption := 'LED is not Lit';

   end; {case}

end;


Example

This example cycles the LED control colour each time it is clicked, changing the Forms caption to reflect the new colour:

procedure TForm1.LED1Click(Sender: TObject);

begin

   case TLED(Sender).ChangeColor of

     lcRed: Caption := 'Red';

     lcGreen: Caption := 'Green';

     lcYellow: Caption := 'Yellow';

   end; {case}

end;


TLED Installation

Included Files

  LEDReg16.PAS	16 bit Delphi registration unit

  LEDReg32.PAS	32 bit Delphi registration unit

  LEDReg16.DCR	16 bit Delphi component palette resource file

  LEDReg32.DCR	32 bit Delphi component palette resource file

  LED.PAS	Delphi TLED component source

  LED_16.RES	16 bit TLED component resource file

  LED_32.RES	32 bit TLED component resource file

  LED_Help.HLP	This TLED Help file

  LED_Help.KWF	Delphi Help key-word file

16 bit Delphi Installation

  Choose Install Components from the Options menu.

  Click the Add button.

  Click the Browse button.

  Find the directory into which you unzipped TLED

  Highlight the file LEDReg16.PAS and click OK.

  Finally click the OK button of the Install Components form.

32 bit Delphi Installation

  Choose Install from the Component menu.

  Click the Add button.

  Click the Browse button.

  Find the directory into which you unzipped TLED

  Highlight the file LEDReg32.PAS and click Open.

  Finally click the OK button of the Install Components form.

Delphi Help File Installation

  Copy the file LED_Help.HLP to Delphi's BIN subdirectory.

  Copy the file LED_Help.KWF to Delphi's HELP subdirectory.

  Change directory to Delphi's HELP subdirectory.

  Run HELPINST.EXE for 16 bit Delphi or TOOLS\HELPINST.EXE for 32 bit Delphi.

  Choose Open from the File menu.

  Open the file DELPHI.HDX found in Delphi's BIN subdirectory.

  Choose Add Keyword File from the Keywords menu.

  Find the file LED_Help.KWF and click OK.

  Choose Save from the File menu.

  When the HDX file has been compiled and saved exit from HELPINST.